package com.atguigu.locks.config;

import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author : leimingchao
 * @date Date : 2021年11月28日 0:16
 */
@Configuration
public class ApplicationJedisConfig {

   /**
    *
    * @param properties
    * @return
    */
   @Bean
    public JedisPool jedisPoolConfig(RedisProperties properties) {
       JedisPoolConfig config = new JedisPoolConfig();
      RedisProperties.Pool pool = properties.getJedis().getPool();
      //这些配置
      config.setMaxIdle(pool.getMaxIdle());
      config.setMaxTotal(pool.getMaxActive());
      JedisPool jedisPool = new JedisPool(config,properties.getHost(),properties.getPort());
       return jedisPool;
   }
}
